package yto.freemarker.springbootstudy.rabbitmq;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import yto.freemarker.springbootstudy.entity.User;

/**
 * 用户对象的传输
 *
 * @author dongxing
 * @create 2018-05-02 10:23
 **/
@Component
public class UserSender {

    @Autowired
    private AmqpTemplate rabbitTemplate;

    public void send() {
        User user = new User();
        user.setName("dx");
        user.setAge(123456789);
        System.out.println("user send : " + user.getName() + "/" + user.getAge());
        this.rabbitTemplate.convertAndSend("user", user);
    }

}
